/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package Jobs;


import Login.MySqlConnector;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.util.logging.Level;
import java.util.logging.Logger;

/**
 *
 * @author sys9
 */
public class JobsubmitDao {
  
    //Declaration here //
    MySqlConnector ms ;
    Connection con;
    PreparedStatement ps ;
    int rs;
    private String query;
    private String tit;
    private String no;
    private String exp;
    private String qual;
    private String cname;
    private String cont;
    private String org;
    private String date;

    public JobsubmitDao()
   {
    ms = new MySqlConnector() ;
   }
   public  boolean insert(JobsubmitBean jbean)
   {
   try {
        con = ms.Connect();
        con.setAutoCommit(false);
        tit = jbean.getTitle();
        no = jbean.getNum();
        exp = jbean.getExp();
        qual = jbean.getQual();
        cname = jbean.getCname();
        cont = jbean.getContact();
        org = jbean.getOrg();
        date = jbean.getReg_date();
    query = "insert into jobsubmit values(null , '"+tit+"','"+no+"','"+exp+"','"+qual+"','"+cname+"','"+cont+"','"+org+"','1','"+date+"' ) ;";
    ps = con.prepareStatement(query);
    rs = ps.executeUpdate();
    System.out.println("Query Inserted "+ps);
    if (rs == 1)
    {
        con.commit();
        return true;
    }
   } catch (Exception ex) {
            Logger.getLogger(JobsubmitDao.class.getName()).log(Level.SEVERE, null, ex);
        }
    return false;
   }

    public boolean delete(String rcheck) throws Exception {
        try {
            con = ms.Connect();
            query = "delete FROM jobsubmit where sno = '"+rcheck+"';";
            ps = con.prepareStatement(query);
            int i = ps.executeUpdate();
            if (i == 1)
                    return true;
            }catch(Exception ex)
            {
                ex.printStackTrace();
            }
       return false;
    }

}
